a11y: Handle relations in UI files
authorEmmanuele Bassi <ebassi@gnome.org>
Wed, 21 Oct 2020 13:48:49 +0000 (14:48 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Wed, 21 Oct 2020 13:48:49 +0000 (14:48 +0100)
A bit hacky: we skip parsing values that have a reference or
reference-list type, but we do not error out. Instead, we return a NULL
value, which we catch in the GtkBuildable interface implementation to
get the actual object, and construct a reference list value.

There's still some ickyness around the value type that can only be
solved by having an attribute and role taxonomy.

gtk/gtkaccessiblevalue.c
gtk/gtkwidget.c

index 45bf824648b7b286654ba5acf4eb312c93fa2816..5a4edd5d852883956e9af5f833c5ef13294d524d 100644 (file)
@@ -1445,11 +1445,10 @@ gtk_accessible_value_parse (const GtkAccessibleCollect  *cstate,
     case GTK_ACCESSIBLE_COLLECT_REFERENCE:
     case GTK_ACCESSIBLE_COLLECT_REFERENCE_LIST:
       {
+        /* We do not error out, to let the caller code deal
+         * with the references themselves
+         */
         res = NULL;
-        g_set_error (error, GTK_ACCESSIBLE_VALUE_ERROR,
-                     GTK_ACCESSIBLE_VALUE_ERROR_INVALID_VALUE,
-                     "Invalid relation “%s”",
-                     str);
       }
       break;
 
index 8747e8efcdd19b47ab6b06a6bb3b2f54ea77096a..aa85cb6ddba0a9e515c3740119c01f30c40b6ba6 100644 (file)
@@ -8831,6 +8831,23 @@ gtk_widget_buildable_finish_accessibility_properties (GtkWidget *widget,
           continue;
         }
 
+      if (value == NULL)
+        {
+          GObject *obj = gtk_builder_get_object (accessibility_data->builder,
+                                                 pinfo->value->str);
+
+          if (obj == NULL)
+            {
+              g_warning ("Failed to find accessible object “%s” for relation “%s”",
+                         pinfo->value->str,
+                         pinfo->name);
+              continue;
+            }
+
+          /* FIXME: Need to distinguish between refs and refslist types */
+          value = gtk_reference_list_accessible_value_new (g_list_append (NULL, obj));
+        }
+
       gtk_at_context_set_accessible_relation (context, relation, value);
       gtk_accessible_value_unref (value);
     }